<div class="modal-header">
  <div class="modal-title">{{ record.ID > 0 ? '编辑 ' + record.name + ' 信息' : '新建' }}</div>
</div>
<nz-spin *ngIf="!i" class="modal-spin"></nz-spin>

<div *ngIf="i">
  <form nz-form [formGroup]="validateForm">
    <input nz-input hidden formControlName="ID" />
    <div nz-col [nzSpan]="20">
      <nz-form-item>
        <nz-form-label [nzSpan]="8" nzRequired nzFor="pid">父级</nz-form-label>
        <nz-form-control [nzSpan]="16">
          <nz-tree-select formControlName="pid" [nzNodes]="parentNodes" nzShowSearch nzPlaceHolder="父级菜单"></nz-tree-select>
        </nz-form-control>
      </nz-form-item>
    </div>

    <div nz-row [nzGutter]="24">
      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="name">名称</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="名称必填！">
            <input nz-input formControlName="name" placeholder="菜单名称" />
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="uri">类型</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="请选择类型">
            <nz-radio-group formControlName="type" (ngModelChange)="typeChange($event)">
              <label nz-radio [nzValue]="0">组节点</label>
              <label nz-radio [nzValue]="1">模块节点</label>
              <label nz-radio [nzValue]="2">路由节点</label>
            </nz-radio-group>
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20" *ngIf="iconShow">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="icon">图标</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="请选择图标！">
            <input nz-input formControlName="icon" placeholder="图标" />
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20" *ngIf="linkShow">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="link">路径</nz-form-label>
          <nz-form-control [nzSpan]="16" nzHasFeedback nzErrorTip="请填写路径！">
            <input nz-input formControlName="link" placeholder="菜单路径" />
          </nz-form-control>
        </nz-form-item>
      </div>

      <div nz-col [nzSpan]="20">
        <nz-form-item>
          <nz-form-label [nzSpan]="8" nzRequired nzFor="sort">排序</nz-form-label>
          <nz-form-control [nzSpan]="16">
            <nz-input-number formControlName="sort" [nzMin]="0" [nzPlaceHolder]="'排序：数字越大排越后'"></nz-input-number>
          </nz-form-control>
        </nz-form-item>
      </div>
    </div>
  </form>
</div>

<div class="modal-footer">
  <button nz-button type="button" (click)="close()">关闭</button>
  <button
    nz-button
    type="submit"
    nzType="primary"
    (click)="save(validateForm.value)"
    [disabled]="!validateForm.valid"
    [nzLoading]="http.loading"
    >保存
  </button>
</div>
